<template>
	<view>
		<component :is="isShowIndex" ref="myChildComponentOne"></component>
		<!-- <tab-bar-view :tabCode="'1'"></tab-bar-view> -->
	</view>
</template>

<script>
	import controlThreeBuildOneFloor from "@/components/dormThreeBuildingOneFloor/control/index.vue"
	import controlThreeBuildTwoFloor from "@/components/dormThreeBuildingTwoFloor/control/index.vue"
	import controlThreeBuildThreeFloor from "@/components/dormThreeBuildingThreeFloor/control/index.vue"
	import controlThreeBuildFourFloor from "@/components/dormThreeBuildingFourFloor/control/index.vue"
	import controlThreeBuildFiveFloor from "@/components/dormThreeBuildingFiveFloor/control/index.vue"

	import controlTwoBuildOneFloor from "@/components/dormTwoBuildingOneFloor/control/index.vue"
	import controlTwoBuildTwoFloor from "@/components/dormTwoBuildingTwoFloor/control/index.vue"
	import controlTwoBuildThreeFloor from "@/components/dormTwoBuildingThreeFloor/control/index.vue"
	import controlTwoBuildFourFloor from "@/components/dormTwoBuildingFourFloor/control/index.vue"
	import controlTwoBuildFiveFloor from "@/components/dormTwoBuildingFiveFloor/control/index.vue"

	import controlOneBuildOneFloor from "@/components/dormOneBuildingOneFloor/control/index.vue"
	import controlOneBuildTwoFloor from "@/components/dormOneBuildingTwoFloor/control/index.vue"
	import controlOneBuildThreeFloor from "@/components/dormOneBuildingThreeFloor/control/index.vue"
	import controlOneBuildFourFloor from "@/components/dormOneBuildingFourFloor/control/index.vue"
	import controlOneBuildFiveFloor from "@/components/dormOneBuildingFiveFloor/control/index.vue"

	import controlElectricianOneBuild from "@/components/electricianOneBuild/control/index.vue"
	import controlElectricianTwoBuild from "@/components/electricianTwoBuild/control/index.vue"
	import controlElectricianThreeBuild from "@/components/electricianThreeBuild/control/index.vue"
	export default {
		components: {
			controlThreeBuildOneFloor,
			controlThreeBuildTwoFloor,
			controlThreeBuildThreeFloor,
			controlThreeBuildFourFloor,
			controlThreeBuildFiveFloor,
			controlTwoBuildOneFloor,
			controlTwoBuildTwoFloor,
			controlTwoBuildThreeFloor,
			controlTwoBuildFourFloor,
			controlTwoBuildFiveFloor,
			controlOneBuildOneFloor,
			controlOneBuildTwoFloor,
			controlOneBuildThreeFloor,
			controlOneBuildFourFloor,
			controlOneBuildFiveFloor,
			controlElectricianOneBuild,
			controlElectricianTwoBuild,
			controlElectricianThreeBuild
		},
		data() {
			return {
				activeMenu: "",
				isShowIndex: "",
			};
		},
		onLoad(query) {
			this.activeMenu = query.activeMenu
		},
		onShow() {
			this.switchShowPage(this.activeMenu)

			// this.$refs.myChildComponentOne.setupTimer();
		},
		onReady() {
			// 隐藏导航栏
			uni.hideTabBar({});
		},
		onUnload() {
			this.$refs.myChildComponentOne.clearTimer();
		},
		methods: {
			switchShowPage(data) {
				const _this = this
				switch (data) {
					case '3-1':
						_this.isShowIndex = 'controlThreeBuildOneFloor'
						break;
					case '3-2':
						_this.isShowIndex = 'controlThreeBuildTwoFloor'
						break;
					case '3-3':
						_this.isShowIndex = 'controlThreeBuildThreeFloor'
						break;
					case '3-4':
						_this.isShowIndex = 'controlThreeBuildFourFloor'
						break;
					case '3-5':
						_this.isShowIndex = 'controlThreeBuildFiveFloor'
						break;
					case '2-1':
						_this.isShowIndex = 'controlTwoBuildOneFloor'
						break;
					case '2-2':
						_this.isShowIndex = 'controlTwoBuildTwoFloor'
						break;
					case '2-3':
						_this.isShowIndex = 'controlTwoBuildThreeFloor'
						break;
					case '2-4':
						_this.isShowIndex = 'controlTwoBuildFourFloor'
						break;
					case '2-5':
						_this.isShowIndex = 'controlTwoBuildFiveFloor'
						break;
					case '1-1':
						_this.isShowIndex = 'controlOneBuildOneFloor'
						break;
					case '1-2':
						_this.isShowIndex = 'controlOneBuildTwoFloor'
						break;
					case '1-3':
						_this.isShowIndex = 'controlOneBuildThreeFloor'
						break;
					case '1-4':
						_this.isShowIndex = 'controlOneBuildFourFloor'
						break;
					case '1-5':
						_this.isShowIndex = 'controlOneBuildFiveFloor'
						break;
					case 'dg-1':
						_this.isShowIndex = 'controlElectricianOneBuild'
						break;
					case 'dg-2':
						_this.isShowIndex = 'controlElectricianTwoBuild'
						break;
					case 'dg-3':
						_this.isShowIndex = 'controlElectricianThreeBuild'
						break;
					default:
						// 如果 expression 不匹配任何 case 值，则执行 default 子句中的代码块  
						break;
				}
			},

			goPage(url) {
				uni.navigateTo({
					url
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	page {
		background-color: #f5f5f5;
	}
</style>